package com.zzzzzz.oms.temporary;


import javax.annotation.Resource;
import org.springframework.stereotype.Repository;
import com.zzzzzz.plugins.jdbctemplate.BaseDao;
import com.zzzzzz.plugins.jdbctemplate.Finder;
@Repository
public class TemporaryDao {
	@Resource
	private BaseDao baseDao;
	
	// SQL 增、查、改
	private final static String sql_add ="insert into t_temporary(cd,val,platformId) values(:cd,:val,:platformId)";
	private final static String sql_upd="update t_temporary set cd=:cd,val=:val,platformId=:platformId where platformId=:platformId";
	private final static String sql_findTemporary="select id,cd,val,platformId from t_temporary where platformId=:platformId";
	
	// 增加
	public Long add(Temporary temporary){
		return baseDao.updateGetLongKey(sql_add, temporary);
	}
	
	// 修改数据
	public int updById(String cd,int val,Long platformId){
		Finder finder = new Finder(sql_upd).setParam("cd", cd).setParam("val", val).setParam("platformId", platformId);
		return baseDao.update(finder);
	}
	
	// 查找
	public Temporary findTemporary(Long platformId){
		Finder finder = new Finder(sql_findTemporary).setParam("platformId", platformId);
		return baseDao.findOne(finder, Temporary.class);
	}
}